package com.gxs.ea.fileportal.model.persisted;

import java.util.ArrayList;

import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;

import com.gxs.ea.fileportal.domain.CompanyMetaConfig;
import com.gxs.ea.fileportal.domain.Field;

//
// We should have been able to simply extend from BaseCompany class and just update the two fields
// id and companyCode on which we need to put Mongo specific annotations.
// However, Becuase of spring-data defect on ambiguous fields for extended classes, currently
// it's not possible and we are simply duplicating the entire BaseCompany class as Company
@Document
public class Company {
	
	@Id
	private String id;

	@Indexed(unique=true, sparse=false)
	private String companyCode;
	
	private String companyName;
	private String companyCity;
	private String companyCountry;
	private CompanyMetaConfig companyMetaConfig;
	
	public Company()
	{}
	
	public Company(boolean initiatlizeDefaults)
	{
		if(initiatlizeDefaults)
		{
			this.companyMetaConfig = new CompanyMetaConfig();
			// Add default field grouping
			this.companyMetaConfig.getFieldGropuings().add(Field.DEFAULT_FIELD_GROUPING);
			this.companyMetaConfig.getMapOfOrderedFieldsForInputForm().put(Field.DEFAULT_FIELD_GROUPING, new ArrayList<String>());
			this.companyMetaConfig.getMapOfOrderedFieldsForOutputDetailsForm().put(Field.DEFAULT_FIELD_GROUPING, new ArrayList<String>());
			this.companyMetaConfig.getMapOfOrderedFieldsForOutputSummaryTable().put(Field.DEFAULT_FIELD_GROUPING, new ArrayList<String>());

		}
	}
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getCompanyCode() {
		return companyCode;
	}
	public void setCompanyCode(String companyCode) {
		this.companyCode = companyCode;
	}
	public String getCompanyName() {
		return companyName;
	}
	public void setCompanyName(String companyName) {
		this.companyName = companyName;
	}
	public String getCompanyCity() {
		return companyCity;
	}
	public void setCompanyCity(String companyCity) {
		this.companyCity = companyCity;
	}
	public String getCompanyCountry() {
		return companyCountry;
	}
	public void setCompanyCountry(String companyCountry) {
		this.companyCountry = companyCountry;
	}
	public CompanyMetaConfig getCompanyMetaConfig() {
		return companyMetaConfig;
	}
	public void setCompanyMetaConfig(CompanyMetaConfig companyMetaConfig) {
		this.companyMetaConfig = companyMetaConfig;
	}
	
	
}
